from flask import Flask, g, request
from extension import db, cache
from extension import login_manager, mail, socketio, jwt
from config import Config
from views.auth import auth_bp
from views.report import report_blueprint
from views.task import tb
from flask_cors import CORS
from views.load_data import data_crash_bp
from views.support import count_bp

app = Flask(__name__)

app.config.from_object(Config)
db.init_app(app)
login_manager.init_app(app)
mail.init_app(app)
app.secret_key = "YTANG"
socketio.init_app(app, cors_allowed_origins="*", async_mode='threading')
cache.init_app(app)
jwt.init_app(app)
#
with app.app_context():
    db.create_all()

CORS(app, supports_credentials=True)
# 注册auth蓝图
app.register_blueprint(auth_bp, url_prefix='/auth')
#注册report蓝图
app.register_blueprint(report_blueprint, url_prefix='/report')

app.register_blueprint(tb, url_prefix='/task')

app.register_blueprint(data_crash_bp,url_prefix='/load_data')

app.register_blueprint(count_bp, url_prefix='/support')



@app.route('/')
def hello_world():  # put application's code here
    return 'Hello World!'

if __name__ == '__main__':
    app.run(host='192.168.0.113', port=5000)
